import java.util.Date;

import com.techedge.insidetrack.*

class BootStrap {

	def init = {

		servletContext ->
		
		// Users
		User meroni = new User(	userid:'meroni',
								name:'Alessandro Meroni',
								email:'alessandro.meroni@techedgegroup.com',
								webpage:'http://www.techedgegroup.com',
								password:'password')

		User bersani = new User(	userid:'bersani',
									name:'Francesco Bersani',
									email:'francesco.bersani@techedgegroup.com',
									webpage:'http://www.techedgegroup.com',
									password:'password')
		
		User dummy1 = new User(	userid:'jcarter',
								name:'John Carter',
								email:'jcarter@techedgegroup.com',
								webpage:'http://www.techedgegroup.com',
								password:'password')
		User dummy2 = new User(	userid:'luser',
								name:'Lucky User',
								email:'luser@techedgegroup.com',
								webpage:'http://www.techedgegroup.com',
								password:'password')
		User dummy3 = new User(	userid:'anzamediu',
								name:'Arthur Nzamediu',
								email:'anzamediu@techedgegroup.com',
								webpage:'http://www.techedgegroup.com',
								password:'password')

		meroni.save()
		bersani.save()
		dummy1.save()
		dummy2.save()
		dummy3.save()
		
		// Locations
		Location milano = new Location(name:'Milano')
		Location torino = new Location(name:'Torino')
		Location roma = new Location(name:'Roma')
		
		milano.save()
		torino.save()
		roma.save()
		
		//Tracks
		Insidetrack track1 = new Insidetrack(	code:'#01',
												schedule:'02/16/2012 09:30',
												twitterTag:'#februaryInsideTrack',
												language:'english',
												information:'News about almost everything!')
		
		track1.creator = meroni
		
		Insidetrack track2 = new Insidetrack(	code:'#03',
												schedule:'03/17/2012 09:30',
												twitterTag:'#marchInsideTrack',
												language:'english',
												information:'News about almost everything!')
		track2.creator = meroni
		
		Insidetrack track3 = new Insidetrack(	code:'#02',
												schedule:'04/18/2012 09:30',
												twitterTag:'#aprilInsideTrack',
												language:'english',
												information:'News about almost everything!')
		track3.creator = bersani
		
		track1.save()
		track2.save()
		track3.save()
		
		// Sessions
		Tracksession session1 = new Tracksession(	trackNumber:'1',
													starTime:'02/16/2012 10:30',
													endTime:'02/16/2012 10:42',
													description:'Grails Introduction')
		session1.hosts = [bersani]
		session1.insideTrack = track1
		session1.save()

		Tracksession session2 = new Tracksession(	trackNumber:'2',
													starTime:'02/16/2012 11:20',
													endTime:'02/16/2012 11:26',
													description:'Grails 5 Minute Demo')
		session2.hosts = [meroni]
		session2.insideTrack = track1
		session2.save()
		
		Tracksession session3 = new Tracksession(	trackNumber:'3',
													starTime:'02/16/2012 10:40',
													endTime:'02/16/2012 10:46',
													description:'SAP PI 7.3')
		session3.hosts = [dummy2]
		session3.insideTrack = track2
		session3.save()

		}

	
	def destroy = {
	}

}